<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
	<ui:composition template="/templates/padrao.xhtml">
		<ui:define name="barraTitulo">Cadastro de Agenda</ui:define>
		<ui:define name="conteudo">
			<h:form id="form">
				<p:growl id="messages" />
				<p:tabView id="divTabView">
					<p:tab title="Cadastro">
						<h:outputText value="Advogado:" styleClass="select" />
						<h:selectOneMenu value="#{controleAgenda.advogado}" >  
							<f:selectItem itemLabel="selecione" itemValue="#{controleAgenda.advogadoSelecione}"/>
		                    <f:selectItems value="#{controleAgenda.advogados}" var="advogado" itemLabel="#{advogado.pessoa.nome}" itemValue="#{advogado}"/>
		                    <f:converter converterId="advogadoConverte"/>
		                    <p:ajax listener="#{controleAgenda.lerEventos}" update="agenda" />
						</h:selectOneMenu>
						<p:schedule value="#{controleAgenda.eventModel}" 
							id="agenda"
							editable="true" widgetVar="myschedule"
							eventSelectListener="#{controleAgenda.onEventSelect}"
							dateSelectListener="#{controleAgenda.onDateSelect}"
							eventMoveListener="#{controleAgenda.onEventMove}"
							onEventMoveUpdate="messages" 
							onDateSelectUpdate="detalhes"
							onDateSelectComplete="eventDialog.show()"
							onEventSelectUpdate="detalhes"
							onEventSelectComplete="eventDialog.show()">
						</p:schedule>
						<p:dialog widgetVar="eventDialog" header="Evento" height="200" width="550"
							showEffect="clip" hideEffect="clip">
							<h:panelGrid id="detalhes" columns="2">
								<h:column>
										<h:outputText value="Descri&ccedil;&atilde;o:" />
								</h:column>
								<h:column>
									<p:inputText id="title" value="#{controleAgenda.event.title}" size="70" />
								</h:column>	
								<h:outputText value="Data:" />
								<p:inputMask id="from" mask="99/99/9999 99:99:99"
									value="#{controleAgenda.event.startDate}">
									<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
								</p:inputMask>
								<p:commandButton type="reset" value="cancelar" />
								<p:commandButton value="Salvar"
									oncomplete="myschedule.update();eventDialog.hide();"
									actionListener="#{controleAgenda.addEvent}" />
							</h:panelGrid>
						</p:dialog>
					</p:tab>
				</p:tabView>
			</h:form>
		</ui:define>
	</ui:composition>
</html>